<?php
function code(){  
$REDIRECT_URI='';
$scope='snsapi_base'; //静默授权 关注用户默认的权限
//$scope='snsapi_userinfo'; //用户点击授权  未关注也可以获取
$url='http://open.weixin.qq.com/connect/oauth2/authorize?appid='.APPID.'&redirect_uri='.urlencode($REDIRECT_URI).'&response_type=code&scope='.$scope.'&state=123#wechat_redirect';
$recode= file_get_contents($url);


 header("Location:".$url);
}  
?>